﻿using Ionic.Zip;
using System;
using System.IO;

namespace ZipBinaryFiles
{
    public class Program
    {
        private const string ZipFileName = @"Zip File   .zip";
        //private const string UnzipDirectory = @".\Unzipped";

        public static void ZipFiles(string zipFile, params string[] filesToZip)
        {
            using (ZipFile zip = new ZipFile())
            {
                foreach (string file in filesToZip)
                {
                    zip.AddFile(file, ".");
                }
                zip.Save(zipFile);
            }
        }

        public static void UnzipFiles(string zipFile, string unzipDirectory)
        {
            using (ZipFile zip = new ZipFile(zipFile))
            {
                zip.ExtractAll(unzipDirectory, ExtractExistingFileAction.OverwriteSilently);
            }
        }

        public  static void Main()
        {
            string[] filesToZip = 
            {
                @"..\..\Program.cs",
                @"C:\Windows\System32\notepad.exe"
            };
            ZipFiles(ZipFileName, filesToZip);

            FileInfo zipFile = new FileInfo(ZipFileName);
            string unzipDirectory = zipFile.FullName;
            unzipDirectory = unzipDirectory.Replace(".zip", "");

            UnzipFiles(ZipFileName, unzipDirectory);
        }
    }
}
